<template>
  <!-- 明细页面弹出框-->
  <el-dialog
    title="数字证书下载查询明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="true"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" label-width="140px" :disabled="true">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="交易流水号：" prop="id">
            <el-input v-model="formData.id" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="报文标识号：" prop="pkgId">
            <el-input v-model="formData.pkgId" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="工作日期：" prop="workdate" label-width="130px">
            <el-date-picker
              v-model="formData.workdate"
              type="date"
              value-format="yyyyMMdd"
              placeholder=""
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="CPG日期：" prop="cpgDate" label-width="130px">
            <el-date-picker
              v-model="formData.cpgDate"
              type="date"
              value-format="yyyyMMdd"
              placeholder=""
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="系统编号：" prop="sysCode">
            <el-select v-model="formData.sysCode" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.SYS_CODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="来往标识：" prop="drct">
            <el-select v-model="formData.drct" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.DRCTCODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="报文类型：" prop="pkgType">
            <el-select v-model="formData.pkgType" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.PKG_TYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="发起参与机构号：" prop="sender">
            <el-input v-model="formData.sender" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="发起参与机构名称：" prop="senderName">
            <el-input v-model="formData.senderName" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="接收参与机构号：" prop="rcver">
            <el-input v-model="formData.rcver" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="接收参与机构名称：" prop="rcverName">
            <el-input v-model="formData.rcverName" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="通讯状态：" prop="status">
            <el-select v-model="formData.status" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.PKG_STATUS"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="中心状态：" prop="procStatus">
            <el-select v-model="formData.procStatus" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.PROCESSSTATUS"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="备注：" prop="remarks">
            <el-input type="textarea" v-model="formData.remarks" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="录入操作员：" prop="mdTlrno">
            <el-input v-model="formData.mdTlrno" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入时间：" prop="mdTime">
            <el-date-picker
              v-model="formData.mdTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder=""
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="报文发送时间：" prop="sndTime">
            <el-date-picker
              v-model="formData.sndTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder=""
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="通用报文处理码：" prop="processCode">
            <el-input v-model="formData.processCode" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :initData="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :showRightToolbar="false"
      defaultEventKey="detailsTable"
      style="height: 240px"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('detials', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">关闭</el-button>
    </div>
    <!-- 明细弹出框 -->
    <details-dialog ref="detailsDialog" :dictMap="dictMap" :innerFormData.sync="innerFormData"></details-dialog>
  </el-dialog>
</template>
<script>
import { detailsApiUrlConfig, innerDetailsQuery } from "@/api/cnaps/ccms/903/digital_certificate_download_query.js";
import DetailsDialog from "./DigitalCertificateDownloadQueryInnerDetails";

export default {
  name: "DigitalCertificateDownloadQueryDetails",
  components: { DetailsDialog },

  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
    id: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      reqConfig: detailsApiUrlConfig,
      // 查询参数
      queryParams: {
        id: "",
      },
      innerFormData: {
        sign: "",
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "250", align: "center" },
        {
          label: `参与机构`,
          prop: "directSender",
          width: "250",
          align: "center",
        },
        {
          label: `参与机构名称`,
          prop: "directSenderName",
          width: "250",
          align: "center",
        },
      ],
      // 是否显示弹出层
      open: false,
    };
  },
  mounted() {},
  watch: {
    open(d) {
      if (d) {
        this.$nextTick(() => {
          this.$set(this.queryParams, "id", this.id);
          this.$refs.dataTable.doQuery();
        });
      }
    },
  },
  methods: {
    /** 明细按钮操作 */
    handleAction(type, row) {
      switch (type) {
        case "detials":
          // 明细信息
          innerDetailsQuery(row).then((res) => {
            this.innerFormData = res.result;
          });
          this.$refs.detailsDialog.show();
          break;
      }
    },
    // 表单重置
    reset() {
      this.resetForm("logForm");
    },
    closeFn() {
      this.open = false;
    },
    show() {
      this.open = true;
    },
    cancel() {
      this.open = false;
      this.reset();
    },
  },
};
</script>
